<?php

abstract class Dcmp_Model_Tag extends Dcmp_Model_Status {

    protected $tagType = NULL;

    public function __construct() {
        parent::__construct();
    }

    protected function afterInsert($transaction) {
        if ($this->issetData('tag')) {
            App::getHelper('tag')->registerSearchableRecord(explode(' ', $this->getTag()), $this->getId(), $this->tagType);
        }
    }

    protected function afterUpdate($transaction) {
        if ($this->propertyIsChanged('tag')) {
            App::getHelper('tag')->unregisterSearchableRecord($this->getId(), $this->tagType)
                                 ->registerSearchableRecord(explode(' ', $this->getTag()), $this->getId(), $this->tagType);
        }
    }

    protected function initializeTable($table) {
        $table->createColumn('tag', 'string');
        parent::initializeTable($table);
    }

}